/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.vcms.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import com.vportal.portlet.vcms.model.VcmsPortion;
import com.vportal.portlet.vcms.model.VcmsPortionModel;
import com.vportal.portlet.vcms.model.VcmsPortionSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the VcmsPortion service. Represents a row in the &quot;VcmsPortion&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.vcms.model.VcmsPortionModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link VcmsPortionImpl}.
 * </p>
 *
 * @author hai
 * @see VcmsPortionImpl
 * @see com.vportal.portlet.vcms.model.VcmsPortion
 * @see com.vportal.portlet.vcms.model.VcmsPortionModel
 * @generated
 */
@JSON(strict = true)
public class VcmsPortionModelImpl extends BaseModelImpl<VcmsPortion>
	implements VcmsPortionModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a vcms portion model instance should use the {@link com.vportal.portlet.vcms.model.VcmsPortion} interface instead.
	 */
	public static final String TABLE_NAME = "VcmsPortion";
	public static final Object[][] TABLE_COLUMNS = {
			{ "portionId", Types.VARCHAR },
			{ "groupId", Types.BIGINT },
			{ "companyId", Types.BIGINT },
			{ "createdDate", Types.TIMESTAMP },
			{ "createdByUser", Types.VARCHAR },
			{ "modifiedDate", Types.TIMESTAMP },
			{ "modifiedByUser", Types.VARCHAR },
			{ "code_", Types.VARCHAR },
			{ "name", Types.VARCHAR },
			{ "description", Types.VARCHAR },
			{ "categorizable", Types.BOOLEAN },
			{ "language", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table VcmsPortion (portionId VARCHAR(75) not null primary key,groupId LONG,companyId LONG,createdDate DATE null,createdByUser VARCHAR(75) null,modifiedDate DATE null,modifiedByUser VARCHAR(75) null,code_ VARCHAR(75) null,name VARCHAR(500) null,description VARCHAR(1000) null,categorizable BOOLEAN,language VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table VcmsPortion";
	public static final String ORDER_BY_JPQL = " ORDER BY vcmsPortion.modifiedDate DESC";
	public static final String ORDER_BY_SQL = " ORDER BY VcmsPortion.modifiedDate DESC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.vcms.model.VcmsPortion"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.vcms.model.VcmsPortion"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.vcms.model.VcmsPortion"),
			true);
	public static long CATEGORIZABLE_COLUMN_BITMASK = 1L;
	public static long CODE_COLUMN_BITMASK = 2L;
	public static long GROUPID_COLUMN_BITMASK = 4L;
	public static long LANGUAGE_COLUMN_BITMASK = 8L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static VcmsPortion toModel(VcmsPortionSoap soapModel) {
		VcmsPortion model = new VcmsPortionImpl();

		model.setPortionId(soapModel.getPortionId());
		model.setGroupId(soapModel.getGroupId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setCreatedDate(soapModel.getCreatedDate());
		model.setCreatedByUser(soapModel.getCreatedByUser());
		model.setModifiedDate(soapModel.getModifiedDate());
		model.setModifiedByUser(soapModel.getModifiedByUser());
		model.setCode(soapModel.getCode());
		model.setName(soapModel.getName());
		model.setDescription(soapModel.getDescription());
		model.setCategorizable(soapModel.getCategorizable());
		model.setLanguage(soapModel.getLanguage());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<VcmsPortion> toModels(VcmsPortionSoap[] soapModels) {
		List<VcmsPortion> models = new ArrayList<VcmsPortion>(soapModels.length);

		for (VcmsPortionSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.vcms.model.VcmsPortion"));

	public VcmsPortionModelImpl() {
	}

	public String getPrimaryKey() {
		return _portionId;
	}

	public void setPrimaryKey(String primaryKey) {
		setPortionId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return _portionId;
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey((String)primaryKeyObj);
	}

	public Class<?> getModelClass() {
		return VcmsPortion.class;
	}

	public String getModelClassName() {
		return VcmsPortion.class.getName();
	}

	@JSON
	public String getPortionId() {
		if (_portionId == null) {
			return StringPool.BLANK;
		}
		else {
			return _portionId;
		}
	}

	public void setPortionId(String portionId) {
		_portionId = portionId;
	}

	@JSON
	public long getGroupId() {
		return _groupId;
	}

	public void setGroupId(long groupId) {
		_columnBitmask |= GROUPID_COLUMN_BITMASK;

		if (!_setOriginalGroupId) {
			_setOriginalGroupId = true;

			_originalGroupId = _groupId;
		}

		_groupId = groupId;
	}

	public long getOriginalGroupId() {
		return _originalGroupId;
	}

	@JSON
	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	@JSON
	public Date getCreatedDate() {
		return _createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		_createdDate = createdDate;
	}

	@JSON
	public String getCreatedByUser() {
		if (_createdByUser == null) {
			return StringPool.BLANK;
		}
		else {
			return _createdByUser;
		}
	}

	public void setCreatedByUser(String createdByUser) {
		_createdByUser = createdByUser;
	}

	@JSON
	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_columnBitmask = -1L;

		_modifiedDate = modifiedDate;
	}

	@JSON
	public String getModifiedByUser() {
		if (_modifiedByUser == null) {
			return StringPool.BLANK;
		}
		else {
			return _modifiedByUser;
		}
	}

	public void setModifiedByUser(String modifiedByUser) {
		_modifiedByUser = modifiedByUser;
	}

	@JSON
	public String getCode() {
		if (_code == null) {
			return StringPool.BLANK;
		}
		else {
			return _code;
		}
	}

	public void setCode(String code) {
		_columnBitmask |= CODE_COLUMN_BITMASK;

		if (_originalCode == null) {
			_originalCode = _code;
		}

		_code = code;
	}

	public String getOriginalCode() {
		return GetterUtil.getString(_originalCode);
	}

	@JSON
	public String getName() {
		if (_name == null) {
			return StringPool.BLANK;
		}
		else {
			return _name;
		}
	}

	public void setName(String name) {
		_name = name;
	}

	@JSON
	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	public void setDescription(String description) {
		_description = description;
	}

	@JSON
	public boolean getCategorizable() {
		return _categorizable;
	}

	public boolean isCategorizable() {
		return _categorizable;
	}

	public void setCategorizable(boolean categorizable) {
		_columnBitmask |= CATEGORIZABLE_COLUMN_BITMASK;

		if (!_setOriginalCategorizable) {
			_setOriginalCategorizable = true;

			_originalCategorizable = _categorizable;
		}

		_categorizable = categorizable;
	}

	public boolean getOriginalCategorizable() {
		return _originalCategorizable;
	}

	@JSON
	public String getLanguage() {
		if (_language == null) {
			return StringPool.BLANK;
		}
		else {
			return _language;
		}
	}

	public void setLanguage(String language) {
		_columnBitmask |= LANGUAGE_COLUMN_BITMASK;

		if (_originalLanguage == null) {
			_originalLanguage = _language;
		}

		_language = language;
	}

	public String getOriginalLanguage() {
		return GetterUtil.getString(_originalLanguage);
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public VcmsPortion toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (VcmsPortion)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		VcmsPortionImpl vcmsPortionImpl = new VcmsPortionImpl();

		vcmsPortionImpl.setPortionId(getPortionId());
		vcmsPortionImpl.setGroupId(getGroupId());
		vcmsPortionImpl.setCompanyId(getCompanyId());
		vcmsPortionImpl.setCreatedDate(getCreatedDate());
		vcmsPortionImpl.setCreatedByUser(getCreatedByUser());
		vcmsPortionImpl.setModifiedDate(getModifiedDate());
		vcmsPortionImpl.setModifiedByUser(getModifiedByUser());
		vcmsPortionImpl.setCode(getCode());
		vcmsPortionImpl.setName(getName());
		vcmsPortionImpl.setDescription(getDescription());
		vcmsPortionImpl.setCategorizable(getCategorizable());
		vcmsPortionImpl.setLanguage(getLanguage());

		vcmsPortionImpl.resetOriginalValues();

		return vcmsPortionImpl;
	}

	public int compareTo(VcmsPortion vcmsPortion) {
		int value = 0;

		value = DateUtil.compareTo(getModifiedDate(),
				vcmsPortion.getModifiedDate());

		value = value * -1;

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		VcmsPortion vcmsPortion = null;

		try {
			vcmsPortion = (VcmsPortion)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		String primaryKey = vcmsPortion.getPrimaryKey();

		if (getPrimaryKey().equals(primaryKey)) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return getPrimaryKey().hashCode();
	}

	@Override
	public void resetOriginalValues() {
		VcmsPortionModelImpl vcmsPortionModelImpl = this;

		vcmsPortionModelImpl._originalGroupId = vcmsPortionModelImpl._groupId;

		vcmsPortionModelImpl._setOriginalGroupId = false;

		vcmsPortionModelImpl._originalCode = vcmsPortionModelImpl._code;

		vcmsPortionModelImpl._originalCategorizable = vcmsPortionModelImpl._categorizable;

		vcmsPortionModelImpl._setOriginalCategorizable = false;

		vcmsPortionModelImpl._originalLanguage = vcmsPortionModelImpl._language;

		vcmsPortionModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<VcmsPortion> toCacheModel() {
		VcmsPortionCacheModel vcmsPortionCacheModel = new VcmsPortionCacheModel();

		vcmsPortionCacheModel.portionId = getPortionId();

		String portionId = vcmsPortionCacheModel.portionId;

		if ((portionId != null) && (portionId.length() == 0)) {
			vcmsPortionCacheModel.portionId = null;
		}

		vcmsPortionCacheModel.groupId = getGroupId();

		vcmsPortionCacheModel.companyId = getCompanyId();

		Date createdDate = getCreatedDate();

		if (createdDate != null) {
			vcmsPortionCacheModel.createdDate = createdDate.getTime();
		}
		else {
			vcmsPortionCacheModel.createdDate = Long.MIN_VALUE;
		}

		vcmsPortionCacheModel.createdByUser = getCreatedByUser();

		String createdByUser = vcmsPortionCacheModel.createdByUser;

		if ((createdByUser != null) && (createdByUser.length() == 0)) {
			vcmsPortionCacheModel.createdByUser = null;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			vcmsPortionCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			vcmsPortionCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		vcmsPortionCacheModel.modifiedByUser = getModifiedByUser();

		String modifiedByUser = vcmsPortionCacheModel.modifiedByUser;

		if ((modifiedByUser != null) && (modifiedByUser.length() == 0)) {
			vcmsPortionCacheModel.modifiedByUser = null;
		}

		vcmsPortionCacheModel.code = getCode();

		String code = vcmsPortionCacheModel.code;

		if ((code != null) && (code.length() == 0)) {
			vcmsPortionCacheModel.code = null;
		}

		vcmsPortionCacheModel.name = getName();

		String name = vcmsPortionCacheModel.name;

		if ((name != null) && (name.length() == 0)) {
			vcmsPortionCacheModel.name = null;
		}

		vcmsPortionCacheModel.description = getDescription();

		String description = vcmsPortionCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			vcmsPortionCacheModel.description = null;
		}

		vcmsPortionCacheModel.categorizable = getCategorizable();

		vcmsPortionCacheModel.language = getLanguage();

		String language = vcmsPortionCacheModel.language;

		if ((language != null) && (language.length() == 0)) {
			vcmsPortionCacheModel.language = null;
		}

		return vcmsPortionCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(25);

		sb.append("{portionId=");
		sb.append(getPortionId());
		sb.append(", groupId=");
		sb.append(getGroupId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", createdDate=");
		sb.append(getCreatedDate());
		sb.append(", createdByUser=");
		sb.append(getCreatedByUser());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", modifiedByUser=");
		sb.append(getModifiedByUser());
		sb.append(", code=");
		sb.append(getCode());
		sb.append(", name=");
		sb.append(getName());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", categorizable=");
		sb.append(getCategorizable());
		sb.append(", language=");
		sb.append(getLanguage());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(40);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.vcms.model.VcmsPortion");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>portionId</column-name><column-value><![CDATA[");
		sb.append(getPortionId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupId</column-name><column-value><![CDATA[");
		sb.append(getGroupId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createdDate</column-name><column-value><![CDATA[");
		sb.append(getCreatedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createdByUser</column-name><column-value><![CDATA[");
		sb.append(getCreatedByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedByUser</column-name><column-value><![CDATA[");
		sb.append(getModifiedByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>code</column-name><column-value><![CDATA[");
		sb.append(getCode());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>name</column-name><column-value><![CDATA[");
		sb.append(getName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>categorizable</column-name><column-value><![CDATA[");
		sb.append(getCategorizable());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>language</column-name><column-value><![CDATA[");
		sb.append(getLanguage());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = VcmsPortion.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			VcmsPortion.class
		};
	private String _portionId;
	private long _groupId;
	private long _originalGroupId;
	private boolean _setOriginalGroupId;
	private long _companyId;
	private Date _createdDate;
	private String _createdByUser;
	private Date _modifiedDate;
	private String _modifiedByUser;
	private String _code;
	private String _originalCode;
	private String _name;
	private String _description;
	private boolean _categorizable;
	private boolean _originalCategorizable;
	private boolean _setOriginalCategorizable;
	private String _language;
	private String _originalLanguage;
	private long _columnBitmask;
	private VcmsPortion _escapedModelProxy;
}